<template>
  <div class="wh-100 " style="background-color: white">
    <div class="w-100 d-flex-between-center  bor-base-b ch50">
      <div class="d-flex-align-center h-100 ">
        <div v-for="(item,index) in topTitle" :key="index" class="ml-20 d-flex-align-center fs-14 h-100 cursor-pointer"
             :class="{'itemActive':item.isActive,'itemNotActive':!item.isActive}" @click="handleClick(index)">
          {{ item.title }}
        </div>
      </div>
      <div class="mr-12">
        <Button type="primary" @click="exportAllData">导出全部数据</Button>
      </div>
    </div>
    <div v-if="topTitle[0].isActive" class="w-100 h-95 pt-12">
      <div class="w-100 h-5   d-flex-align-center">
        <Select v-if="userInfo.resource == 1" v-model="searchFormOne.schoolName" class="w-10 ml-8" clearable filterable
                placeholder="所有高校">
          <Option v-for="item in schoolList" :value="item.name" :key="item.code">{{ item.name }}</Option>
        </Select>
        <Select v-if="userInfo.resource == 1 || userInfo.resource == 2" v-model="searchFormOne.collegeName" filterable
                class="w-15 ml-8" clearable placeholder="所有院系">
          <Option v-for="item in collegeList" :value="item" :key="item">{{ item }}</Option>
        </Select>
        <Input v-model="searchFormOne.profession" placeholder="专业" clearable class="w-10 ml-8" />
        <el-select v-model="searchFormOne.graduationCode" class="w-15 ml-8" size="small" clearable
                   placeholder="毕业去向">
          <el-option
              v-for="item in employmentCategoryList"
              :key="item.profCode"
              :label="item.title.substr(0, 20)"
              :value="item.profCode">
          </el-option>
        </el-select>
        <Input v-model="searchFormOne.enterpriseName" placeholder="单位名称" class="w-20 ml-8" />
        <Input v-model="searchFormOne.studentCard" clearable placeholder="学号" class="w-10 ml-8" />
        <Input v-model="searchFormOne.studentName" clearable placeholder="姓名" class="w-10 ml-8" />
        <Select v-if="userInfo.resource == 1" v-model="searchFormOne.auditType" clearable class="w-10 ml-8"
                placeholder="核查人">
          <Option value="2">学校已核查</Option>
          <Option value="1">省级已核查</Option>
        </Select>
      </div>
      <div class="w-100 h-5    d-flex-align-center ">
        <DatePicker v-if="userInfo.resource == 1" v-model="searchFormOne.auditTimeBegin"
                    @on-change="searchFormOne.auditTimeBegin=$event" type="datetime" placeholder="请选择核查开始时间"
                    class="w-10 ml-8"></DatePicker>
        <DatePicker v-if="userInfo.resource == 1" v-model="searchFormOne.auditTimeEnd"
                    @on-change="searchFormOne.auditTimeEnd=$event" type="datetime" placeholder="请选择核查结束时间"
                    class="w-10 ml-8"></DatePicker>
        <Select v-model="searchFormOne.materialAudit" clearable class="w-15 ml-8" placeholder="材料核查">
          <Option v-for="item in materialVerification" v-if="item.value!= 0" :value="item.value" :key="item.value">
            {{ item.title }}
          </Option>
        </Select>
        <Select v-model="searchFormOne.studentAudit" clearable class="w-15 ml-8" placeholder="学生电话核查">
          <Option v-for="item in studentPhoneCheck" v-if="item.value!= 0" :value="item.value" :key="item.value">
            {{ item.title }}
          </Option>
        </Select>
        <Select v-model="searchFormOne.enterpriseAudit" clearable class="w-15 ml-8" placeholder="用人单位电话核查">
          <Option v-for="item in employerTelephoneVerification" v-if="item.value!= 0" :value="item.value"
                  :key="item.value">{{ item.title }}
          </Option>
        </Select>
        <Button type="primary" @click="searchData">查询</Button>
        <Button @click="downloadSearchData">下载当前查询数据</Button>
      </div>
      <div class="w-100 h-80 mt-8 " v-loading="tableLoading" v-ref-height="refHeight">
        <Table
            :columns="tableColumns"
            :data="tableData"
            :height="refHeight.value"
        >
          <template slot-scope="{ row, index }" slot="action">
            <Button type="primary" @click="selectRowData(row)">查看</Button>
          </template>
        </Table>
      </div>
      <div class="w-100 h-5  d-flex-align-center mt-16 ">
        <Page
            :total="pages.total"
            :page-size="pages.pageSize"
            :current="pages.pageNumber"
            @on-change="changePage"
            @on-page-size-change="changePageSize"
            show-elevator
            show-sizer
            show-total
            class-name="d-flex-center"
            size="small"
        />
      </div>
    </div>
    <div v-if="topTitle[1].isActive" class="w-100 h-95 fs-12">
      <div class="w-100  h-7 d-flex-align-center">
        <Select v-if="userInfo.resource == 1" v-model="searchFormTwo.schoolName" class="w-10 ml-8" clearable
                placeholder="所有高校">
          <Option v-for="item in schoolList" :value="item.name" :key="item.code">{{ item.name }}</Option>
        </Select>
        <Select v-if="userInfo.resource == 1 || userInfo.resource == 2" v-model="searchFormTwo.college"
                class="w-15 ml-8" clearable placeholder="所有院系">
          <Option v-for="item in collegeList" :value="item" :key="item">{{ item }}</Option>
        </Select>
        <Input v-model="searchFormTwo.profession" placeholder="专业" clearable class="w-10 ml-8" />
        <DatePicker v-model="searchFormTwo.auditTimeBegin" @on-change="searchFormTwo.auditTimeBegin=$event"
                    type="datetime" placeholder="请选择核查开始时间" class="w-10 ml-8"></DatePicker>
        <DatePicker v-model="searchFormTwo.auditTimeEnd" @on-change="searchFormTwo.auditTimeEnd=$event" type="datetime"
                    placeholder="请选择核查结束时间" class="w-10 ml-8"></DatePicker>
        <Button type="primary" @click="searchDataTwo">搜索</Button>

      </div>
      <div class="w-100 h-85 " v-ref-height="refHeight">
        <TableV2
            v-loading="tableLoading"
            id="table1"
            class="wh-100"
            show-summary
            :summary-method="handleSum"
            border
            :columns="columnsTwo"
            :data="tableData"
            ref="table1"
            :height="refHeight.value"
        ></TableV2>
      </div>
    </div>
  </div>
</template>

<script>
import { getAllCollege, proGetAllCollage } from '../../api/bys/yx/yx';
import TableV2 from '@/views/xboot-components/table/table-v2.vue';
import { accessToAllNonProvincialSchoolsApi } from '../../api/bys/gxjyl/jyqx';
import {
  exportAllRecordData,
  exportConditionRecordData,
  getAuditRecordDataStatisticApi,
  getByPageDataAuditRecordDataApi
} from '../../api/dataVerification/dataVerification';
import { employerTelephoneVerification, materialVerification, studentPhoneCheck } from './enums';
import { employmentCategoryAPI } from '../../api/bys';
import { saveAs } from 'file-saver';
import XLSX from 'xlsx';
import cloneDeep from 'lodash/cloneDeep';
import { getDictDataByType } from '@/api';

export default {
  components: { TableV2 },

  data() {
    return {
      qxDict: [],
      topTitle: [
        { title: '核查记录', isActive: true },
        { title: '核查记录统计', isActive: false }
      ],
      refHeight: { value: 0 },
      tableLoading: false,
      verifier: '',
      value: '',
      model1: '',
      materialVerification,
      studentPhoneCheck,
      employerTelephoneVerification,
      columnsOne: [],
      columnsOne_1: [
        {
          title: '专业',
          minWidth: 200,
          key: 'profession'
        },
        {
          title: '学号',
          minWidth: 200,
          key: 'studentCard'
        },
        {
          title: '姓名',
          minWidth: 200,
          key: 'studentName'
        },

        {
          title: '省级核查次数',
          minWidth: 200,
          key: 'provinceTotal'
        },
        {
          title: '学校核查次数',
          minWidth: 200,
          key: 'schoolTotal'
        },
        {
          title: '单位名称',
          minWidth: 200,
          key: 'enterpriseName'
        },
        {
          title: '毕业去向',
          minWidth: 150,
          key: 'graduationCode',
          render: (h, params) => {
            let item = this.qxDict.find(item => item.value === params.row.oneType);
            let title = item ? item.title : '';
            return h('div', title);
          }
        },
        {
          title: '去向分类',
          minWidth: 200,
          key: 'qxName'
        },
        {
          title: '联系方式',
          minWidth: 200,
          key: 'studentMobile'
        },
        {
          title: '单位联系人',
          minWidth: 200,
          key: 'enterpriseContact'
        },
        {
          title: '单位联系方式',
          minWidth: 200,
          key: 'enterpriseMobile'
        },
        {
          title: '材料核查',
          minWidth: 300,
          key: 'materialAudit',
          render: (h, params) => {
            let item = this.materialVerification.find(item => item.value == params.row.materialAudit);
            return h('div', item ? item.title : '');
          }
        },
        {
          title: '材料核查说明',
          minWidth: 200,
          key: 'materialAuditMessage'
        },
        {
          title: '学生电话核查',
          width: 300,
          key: 'studentAudit',
          render: (h, params) => {
            let item = this.studentPhoneCheck.find(item => item.value == params.row.studentAudit);
            return h('div', item ? item.title : '');
          }
        },
        {
          title: '学生电话核查说明',
          width: 120,
          key: 'studentAuditMessage'
        },
        {
          title: '用人单位电话核查',
          width: 300,
          key: 'enterpriseAudit',
          render: (h, params) => {
            let item = this.employerTelephoneVerification.find(item => item.value == params.row.enterpriseAudit);
            return h('div', item ? item.title : '');
          }
        },
        {
          title: '用人单位电话核查说明',
          width: 120,
          key: 'enterpriseAuditMessage'
        },
        {
          title: '其他核查情况',
          width: 120,
          key: 'otherAudit'
        },
        {
          title: '核查时间',
          minWidth: 164,
          fixed: 'right',
          key: 'auditTime'
        },
        {
          title: '学校是否核查',
          minWidth: 80,
          fixed: 'right',
          key: 'school'
        },
        {
          title: '省级是否核查',
          minWidth: 80,
          fixed: 'right',
          key: 'province'
        },
        // {
        //   title: '核查人',
        //   minWidth: 110,
        //   fixed: 'right',
        //   key: 'auditType',
        //   render: (h, params) => {
        //     let item = '';
        //     if (params.row.auditType == 1) {
        //       item = '省级已核查';
        //     }
        //     if (params.row.auditType == 2) {
        //       item = '学校已核查';
        //     }
        //     return h('div', item);
        //   }
        // },
        {
          title: '操作',
          slot: 'action',
          align: 'center',
          width: 120,
          fixed: 'right'
        }
      ],
      columnsThree: [],
      columnsThree_1: [
        {
          title: '专业',
          minWidth: 200,
          key: 'profession'
        },
        {
          title: '学号',
          minWidth: 200,
          key: 'studentCard'
        },
        {
          title: '姓名',
          minWidth: 200,
          key: 'studentName'
        },
        {
          title: '省级核查次数',
          minWidth: 200,
          key: 'provinceTotal'
        },
        {
          title: '学校核查次数',
          minWidth: 200,
          key: 'schoolTotal'
        },
        {
          title: '单位名称',
          minWidth: 200,
          key: 'enterpriseName'
        },
        {
          title: '毕业去向',
          minWidth: 150,
          key: 'graduationCode',
          render: (h, params) => {
            let item = this.qxDict.find(item => item.value === params.row.oneType);
            let title = item ? item.title : '';
            return h('div', title);
          }
        },
        {
          title: '去向分类',
          minWidth: 200,
          key: 'qxName'
        },
        {
          title: '联系方式',
          minWidth: 200,
          key: 'studentMobile'
        },
        {
          title: '单位联系人',
          minWidth: 200,
          key: 'enterpriseContact'
        },
        {
          title: '单位联系方式',
          minWidth: 200,
          key: 'enterpriseMobile'
        },
        {
          title: '材料核查',
          minWidth: 300,
          key: 'materialAudit',
          render: (h, params) => {
            let item = this.materialVerification.find(item => item.value == params.row.materialAudit);
            return h('div', item ? item.title : '');
          }
        },
        {
          title: '材料核查说明',
          minWidth: 200,
          key: 'materialAuditMessage'
        },
        {
          title: '学生电话核查',
          width: 300,
          key: 'studentAudit',
          render: (h, params) => {
            let item = this.studentPhoneCheck.find(item => item.value == params.row.studentAudit);
            return h('div', item ? item.title : '');
          }
        },
        {
          title: '学生电话核查说明',
          width: 120,
          key: 'studentAuditMessage'
        },
        {
          title: '用人单位电话核查',
          width: 300,
          key: 'enterpriseAudit',
          render: (h, params) => {
            let item = this.employerTelephoneVerification.find(item => item.value == params.row.enterpriseAudit);
            return h('div', item ? item.title : '');
          }
        },
        {
          title: '用人单位电话核查说明',
          width: 120,
          key: 'enterpriseAuditMessage'
        },
        {
          title: '其他核查情况',
          width: 120,
          key: 'otherAudit'
        },
        {
          title: '核查时间',
          minWidth: 120,
          fixed: 'right',
          key: 'auditTime'
        },
        {
          title: '学校是否核查',
          minWidth: 80,
          fixed: 'right',
          key: 'school'
        },
        {
          title: '省级是否核查',
          minWidth: 80,
          fixed: 'right',
          key: 'province'
        },
        {
          title: '操作',
          slot: 'action',
          align: 'center',
          width: 120,
          fixed: 'right'
        }
      ],
      tableColumns: [],
      tableColumns_1: [
        {
          title: '专业',
          minWidth: 200,
          key: 'profession'
        },
        {
          title: '学号',
          minWidth: 200,
          key: 'studentCard'
        },
        {
          title: '姓名',
          minWidth: 200,
          key: 'studentName'
        },
        {
          title: '省级核查次数',
          minWidth: 200,
          key: 'provinceTotal'
        },
        {
          title: '学校核查次数',
          minWidth: 200,
          key: 'schoolTotal'
        },
        {
          title: '单位名称',
          minWidth: 200,
          key: 'enterpriseName'
        },
        {
          title: '毕业去向',
          minWidth: 150,
          key: 'graduationCode',
          render: (h, params) => {
            let item = this.qxDict.find(item => item.value === params.row.oneType);
            let title = item ? item.title : '';
            return h('div', title);
          }
        },
        {
          title: '去向分类',
          minWidth: 200,
          key: 'qxName'
        },
        {
          title: '联系方式',
          minWidth: 200,
          key: 'studentMobile'
        },
        {
          title: '单位联系人',
          minWidth: 200,
          key: 'enterpriseContact'
        },
        {
          title: '单位联系方式',
          minWidth: 200,
          key: 'enterpriseMobile'
        },
        {
          title: '材料核查',
          minWidth: 300,
          key: 'materialAudit',
          render: (h, params) => {
            let item = this.materialVerification.find(item => item.value == params.row.materialAudit);
            return h('div', item ? item.title : '');
          }
        },
        {
          title: '材料核查说明',
          minWidth: 200,
          key: 'materialAuditMessage'
        },
        {
          title: '学生电话核查',
          width: 300,
          key: 'studentAudit',
          render: (h, params) => {
            let item = this.studentPhoneCheck.find(item => item.value == params.row.studentAudit);
            return h('div', item ? item.title : '');
          }
        },
        {
          title: '学生电话核查说明',
          width: 120,
          key: 'studentAuditMessage'
        },
        {
          title: '用人单位电话核查',
          width: 300,
          key: 'enterpriseAudit',
          render: (h, params) => {
            let item = this.employerTelephoneVerification.find(item => item.value == params.row.enterpriseAudit);
            return h('div', item ? item.title : '');
          }
        },
        {
          title: '用人单位电话核查说明',
          width: 120,
          key: 'enterpriseAuditMessage'
        },
        {
          title: '其他核查情况',
          width: 120,
          key: 'otherAudit'
        },
        {
          title: '核查时间',
          minWidth: 120,
          fixed: 'right',
          key: 'auditTime'
        },
        {
          title: '学校是否核查',
          minWidth: 80,
          fixed: 'right',
          key: 'school'
        },
        {
          title: '省级是否核查',
          minWidth: 80,
          fixed: 'right',
          key: 'province'
        },
        {
          title: '操作',
          slot: 'action',
          align: 'center',
          width: 120,
          fixed: 'right'
        }
      ],
      columnsTwo: [],
      columnsTwo_1: [
        {
          title: '专业',
          key: 'profession',
          minWidth: 200,
          align: 'center',
          sortable: true
        },
        {
          title: '总计',
          key: 'total',
          minWidth: 80,
          align: 'center',
          sortable: true
        },
        {
          title: '材料核查',
          key: '',
          minWidth: 100,
          align: 'center',
          sortable: false,
          children: [
            {
              title: '材料完整且与毕业去向一致',
              key: 'materialComplete',
              minWidth: 220,
              sortable: true,
              disability: false
            },
            {
              title: '材料不完整',
              key: 'materialNoComplete',
              minWidth: 130,
              sortable: true
            },
            {
              title: '材料与毕业去向不一致',
              key: 'materialInconsistent',
              minWidth: 200,
              sortable: true
            }
          ]
        },
        {
          title: '学生电话核查',
          key: '',
          minWidth: 100,
          align: 'center',
          sortable: false,
          children: [
            {
              title: '毕业去向信息无误',
              key: 'studentComplete',
              minWidth: 170,
              sortable: true,
              disability: false
            },
            {
              title: '毕业去向信息有误，曾经在此单位工作，目前未就业',
              key: 'studentInNotEmployed',
              minWidth: 380,
              sortable: true
            },
            {
              title: '毕业去向信息有误，曾经在此单位工作，目前已换工作单位',
              key: 'studentInChangedEmployer',
              minWidth: 380,
              sortable: true
            },
            {
              title: '毕业去向信息有误，学生从未登记该毕业去向信息或该毕业去向信息与学生无关，目前已就业',
              key: 'studentNeverIsEmployed',
              minWidth: 380,
              sortable: true,
              disability: false
            },
            {
              title: '毕业去向信息有误，学生从未登记该毕业去向信息或该毕业去向信息与学生无关，目前未就业',
              key: 'studentNeverNotEmployed',
              minWidth: 380,
              sortable: true
            }
          ]
        },
        {
          title: '用人单位电话核查',
          key: '',
          minWidth: 100,
          align: 'center',
          sortable: false,
          children: [
            {
              title: '毕业去向信息无误',
              key: 'enterpriseComplete',
              minWidth: 170,
              sortable: true,
              disability: false
            },
            {
              title: '学生与该单位签约过，但已解约或未入职',
              key: 'enterpriseTerminated',
              minWidth: 200,
              sortable: true
            },
            {
              title: '学生在该单位工作过，但已离职',
              key: 'enterpriseLeft',
              minWidth: 170,
              sortable: true
            },
            {
              title: '该单位仅为学生的实习单位',
              key: 'enterpriseInternship',
              minWidth: 170,
              sortable: true,
              disability: false
            },
            {
              title: '该单位与学生没有任何关系',
              key: 'enterpriseNotMatter',
              minWidth: 170,
              sortable: true
            }
          ]
        }
      ],
      tableData: [],
      pages: {
        pageSize: 10,
        pageNumber: 1,
        total: 0
      },
      schoolList: [],
      collegeList: [],
      employmentCategoryList: [],

      searchFormOne: {},
      searchFormTwo: {
        schoolName: '',
        collegeName: '',
        profession: ''
      },
      userInfo: JSON.parse(Cookies.get('userInfo'))

    };
  },
  methods: {
    searchDataTwo() {
      this.getRecordDataStatistics();
    },
    exportAllData() {
      if (this.topTitle[0].isActive) {
        exportAllRecordData().then(res => {
          // type的格式可以可以设置，可以把appcation/json设置进去，然后设置导出的类型
          const blob = new Blob([res], { type: 'charset=utf-8' });
          let url = window.URL.createObjectURL(blob);
          const link = document.createElement('a');
          link.style.display = 'none';
          link.href = url;
          link.setAttribute('download', '核查记录.xlsx');
          document.body.appendChild(link);
          link.click();
          document.body.removeChild(link); // 删除节点
          window.URL.revokeObjectURL(url); //释放该 url
        });
      }
      if (this.topTitle[1].isActive) {
        this.exportAllStatisticsData();
      }
    },
    exportAllStatisticsData() {
      let elementId = 'table1';
      let excelName = '核查记录统计数据.xlsx';
      // 通过table的id获取表格元素
      const table = document.getElementById(elementId);
      const ws = XLSX.utils.table_to_sheet(table, { raw: true });

      // 设置所有列为字符串格式
      const range = XLSX.utils.decode_range(ws['!ref']);
      for (let column = range.s.c; column <= range.e.c; column++) {
        for (let row = range.s.r; row <= range.e.r; row++) {
          const cellRef = XLSX.utils.encode_cell({ c: column, r: row });
          if (!ws[cellRef]) continue;
          ws[cellRef].z = 's';
        }
      }


      // 确定最后一行的行号
      const lastRowNum = range.e.r;
      // 遍历最后一行的每个单元格并删除它们(最后一行为多余数据，暂无筛选结果)
      for (let colIndex = range.s.c; colIndex <= range.e.c; colIndex++) {
        const cellAddress = XLSX.utils.encode_cell({ c: colIndex, r: lastRowNum });
        if (ws[cellAddress]) {
          delete ws[cellAddress]; // 删除单元格
        }
      }


      const wb = XLSX.utils.book_new();
      XLSX.utils.book_append_sheet(wb, ws, 'Sheet1');
      const wbout = XLSX.write(wb, { bookType: 'xlsx', type: 'binary' });

      function s2ab(s) {
        const buf = new ArrayBuffer(s.length);
        const view = new Uint8Array(buf);
        for (let i = 0; i !== s.length; ++i) view[i] = s.charCodeAt(i) & 0xff;
        return buf;
      }

      saveAs(new Blob([s2ab(wbout)], { type: 'application/octet-stream' }), excelName);
    },
    downloadSearchData() {
      exportConditionRecordData(this.searchFormOne).then(res => {
        // type的格式可以可以设置，可以把appcation/json设置进去，然后设置导出的类型
        const blob = new Blob([res], { type: 'charset=utf-8' });
        let url = window.URL.createObjectURL(blob);
        const link = document.createElement('a');
        link.style.display = 'none';
        link.href = url;
        link.setAttribute('download', '当前查询核查记录.xlsx');
        document.body.appendChild(link);
        link.click();
        document.body.removeChild(link); // 删除节点
        window.URL.revokeObjectURL(url); //释放该 url
      });
    },
    searchData() {
      this.pages.pageNumber = 1;
      this.getRecordDataPage();
    },
    employmentCategoryData() {
      employmentCategoryAPI().then(res => {
        this.employmentCategoryList = res.result;
      });
    },
    handleSum({ columns, data }) {
      let userInfo = JSON.parse(Cookies.get('userInfo'));
      const sums = {};
      columns.forEach((column, index) => {
        const key = column.key;
        if (index === 0) {
          sums[key] = {
            key,
            value: '总计'
          };
          return;
        }
        if (index === 1 && (userInfo.resource == 1 || userInfo.resource == 2)) {
          sums[key] = {
            key,
            value: ''
          };
          return;
        }
        if (index === 2 && (userInfo.resource == 1)) {
          sums[key] = {
            key,
            value: ''
          };
          return;
        }
        const values = data.map(item => Number(item[key]));
        if (!values.every(value => isNaN(value))) {
          const v = values.reduce((prev, curr) => {
            const value = Number(curr);
            if (!isNaN(value)) {
              return prev + curr;
            } else {
              return prev;
            }
          }, 0);
          sums[key] = {
            key,
            value: v
          };
        } else {
          sums[key] = {
            key,
            value: ''
          };
        }
      });
      return sums;
    },
    selectRowData(row) {
      this.$router.push({ name: 'CheckDetails', query: { id: row.id,idCard:row.idCard } });
    },
    getSchoolList() {
      // 学校
      accessToAllNonProvincialSchoolsApi().then(res => {
        if (res.success) {
          this.schoolList = res.result;
          let arr = {
            code: 0,
            name: '所有学校'
          };
          this.schoolList.unshift(arr);
          // if (res.result.length > 0) {
          //     this.searchForm.gx = res.result[0].code;
          // }
        }
      });
    },
    getCollegeList() {
      let userInfo = JSON.parse(Cookies.get('userInfo'));
      if (userInfo.resource == 1) {
        proGetAllCollage().then(res => {
          if (res.success) {
            if (res.result.length > 0) {
              this.collegeList = res.result;
            }
            this.showCollapse = true;
          }
        });
      } else if (userInfo.resource == 2) {
        this.showCollapse = true;
        getAllCollege({ gxcode: userInfo.gxcode }).then(res => {
          if (res.success) {
            if (res.result.length > 0) {
              res.result.map(item => {
                this.collegeList.push(item.yxname);
              });
            }
            this.showCollapse = true;
          }
        });
      }

    },
    handleClick(index) {
      this.topTitle[index].isActive = true;
      this.topTitle.forEach((item, i) => {
        if (i !== index) {
          item.isActive = false;
        }
      });
      if (this.topTitle[0].isActive) {
        this.pages.pageNumber = 1;
        this.getRecordDataPage();
      }
      if (this.topTitle[1].isActive) {
        this.getRecordDataStatistics();
      }
    },
    getQxDict() {
      getDictDataByType('qx').then((res) => {
        console.log(res, '字典');
        if (res.success) {
          this.qxDict = res.result;
          console.log(res.result, '字典');
        }
      });
    },
    getRecordDataStatistics() {
      this.tableLoading = true;

      getAuditRecordDataStatisticApi(this.searchFormTwo).then((res) => {
        this.tableData = res.result;
        this.tableLoading = false;
        console.log('核查记录统计', res);
      });
    },
    getRecordDataPage() {
      this.tableLoading = true;
      getByPageDataAuditRecordDataApi({ ...this.pages, ...this.searchFormOne }).then(res => {
        console.log('核查记录', res);
        this.tableData = res.result.records;
        this.pages.total = res.result.total || 0;
        this.tableLoading = false;
      });
    },
    changePage: function(val) {
      this.pages.pageNumber = val;
      if (this.topTitle[0].isActive) {
        this.getRecordDataPage();
      }
      if (this.topTitle[1].isActive) {
        this.getRecordDataStatistics();
      }
      // this.jobListingData();
    },
    changePageSize: function(val) {
      this.pages.pageSize = val;
      if (this.topTitle[0].isActive) {
        this.getRecordDataPage();
      }
      if (this.topTitle[1].isActive) {
        this.getRecordDataStatistics();
      }
      // this.jobListingData();
    },
    onRestWindow() {
      this.columnsOne = this.restTableCellWidth(this.columnsOne_1);
      this.columnsThree = this.restTableCellWidth(this.columnsThree_1);
      this.tableColumns = this.restTableCellWidth(this.tableColumns_1);
      let t1 = cloneDeep(this.columnsTwo_1);
      this.restTreeTableCellWidth(t1);
      this.columnsTwo = t1;
      // this.labelWidth80 = this.searchLabelWidth(this.labelWidth80)
      // this.labelWidth100 = this.searchLabelWidth(this.labelWidth100)
    }

  },
  mounted() {
    this.onRestWindow();
    window.addEventListener('resize', this.onRestWindow);
    let userInfo = JSON.parse(Cookies.get('userInfo'));
    if (userInfo.resource == 1) {
      let arr = [
        {
          type: 'index',
          title: '序号',
          width: 60,
          align: 'center'
        },
        {
          title: '学校',
          minWidth: 200,
          key: 'schoolName'
        },
        {
          title: '院系',
          minWidth: 200,
          key: 'college'
        }
      ];

      let arr1 = [
        {
          title: '高校名称',
          key: 'schoolName',
          minWidth: 200,
          align: 'center',
          sortable: true
        },
        {
          title: '院系名称',
          key: 'college',
          minWidth: 200,
          align: 'center',
          sortable: true
        }
      ];
      let arr01 = this.restTableCellWidth(arr);
      let arr02 = this.restTableCellWidth(arr1);
      this.tableColumns = arr01.concat(this.columnsOne);
      this.columnsTwo = arr02.concat(this.columnsTwo);
    }
    if (userInfo.resource == 2) {
      let arr = [
        {
          type: 'index',
          title: '序号',
          width: 60,
          align: 'center'
        },
        {
          title: '院系',
          minWidth: 200,
          key: 'college'
        }
      ];
      let arr1 = [
        {
          title: '院系名称',
          key: 'college',
          minWidth: 200,
          align: 'center',
          sortable: true
        }
      ];
      let arr01 = this.restTableCellWidth(arr);
      let arr02 = this.restTableCellWidth(arr1);
      this.tableColumns = arr01.concat(this.columnsThree);
      this.columnsTwo = arr02.concat(this.columnsTwo);

    }
    this.getCollegeList();
    this.getSchoolList();
    this.employmentCategoryData();
    this.getRecordDataPage();
    this.getQxDict();
  },
  beforeDestroy() {
    window.removeEventListener('resize', this.onRestWindow);
  }
};
</script>

<style scoped lang="less">
.h—5j24p {
  height: calc(5% + 15px);
}

.h-93 {
  height: 93%;
}

.h-7 {
  height: 7%;
}

.itemActive {
  border-bottom: 4px solid #2873f3;
  color: #2873f3;
}

.itemNotActive {
  margin-bottom: 4px;
}

.ch50 {
  height: 50px;
}


@media (max-width: 1920px) {
  /deep/ .ivu-table .ivu-table-fixed-right {
    height: 98% !important;

  }

  /deep/ .ivu-table .ivu-table-fixed-body {
    height: 91% !important;
    overflow-y: auto;
  }
}

@media (min-width: 1921px) and (max-width: 3440px) {
  /deep/ .ivu-table .ivu-table-fixed-right {
    //height: 98% !important;
  }

  /deep/ .ivu-table .ivu-table-fixed-body {
    //height: 88.5% !important;
    overflow-y: auto;
  }

}

// /deep/ .ivu-table .ivu-table-fixed-right .ivu-table-fixed-body {
//     height: 90% !important;
// }
</style>
